<template>
	<view>
		<view class="top"></view>
		<view v-if="list.length>0">
			<view class="news"  v-for="(item,index) in list" :key="index" @click="moveTo(item)">
				<view class="left">
					<image :src="item.src" mode=""></image>
					<view :class="item.status==0?'red':''"></view>
				</view>		
				<view class="right" >
					<view class="detail">{{item.title}}</view>
					<view class="into iconfont icon-right"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {selectMessageList} from '@/apis/message/index.js'
	export default {
		data() {
			return {
				userId:this.$store.state.userId,
				list:[
				// {
				//  title:'订单消息',
				//  src:'../../../static/img/news/orderMessage.png',
				//  url:"../news-order/news-order",
				//  status:1,
				//  type:0,
				// },
				{
				 title:'系统消息',
				 src:'../../../static/img/news/systemMessage.png',
				 url:"../news-system/news-system",
				 status:1,
				 type:1,
				}]
			}
		},
		onLoad() {
			
		},
		onShow() {
			// this.order(),
			this.system()
			
		},
		methods: {
			moveTo(item){
				uni.navigateTo({					
					url:item.url
				})
			},
			async order(){
				let res =await selectMessageList({messageType:0,nurseId:this.$store.state.userInfo.id})
				if(res.success){
					if(res.data==0){
						this.list[0].status = res.data
						console.log(this.list[0].status)
					}else{
						this.list[0].status = 1
					}
				}
				console.log(res,'订单消息')
			},
			async system(){
				let res =await selectMessageList({messageType:1,nurseId:this.$store.state.userInfo.id})
				if(res.success){
					// if(res.data==0){
					// 	this.list[1].status = res.data
					// 	console.log(this.list[1].status)
					// }else{
					// 	this.list[1].status = 1
					// }
					
					if(res.data==0){
						this.list[0].status = res.data
						console.log(this.list[0].status)
					}else{
						this.list[0].status = 1
					}
				}
				console.log(res,'系统消息')
			},
		}
	}
</script>

<style scoped lang="less">
	.top{
		border-top: 1rpx  rgba(0, 0, 0, 0.1) solid;
	}
	.news{
		height: 160rpx;
		background: #FFFFFF;
		margin-left: 40rpx;
		display: flex;
		align-items: center;
		.left{
			width: 88rpx;
			height: 88rpx;
			// background: #D8D8D8;
			border-radius: 20rpx;
			margin-right: 48rpx;
			position: relative;
			image{
				width: 88rpx;
				height: 88rpx;
				border-radius: 20rpx;
			}
			.red{
				width: 16rpx;
				height: 16rpx;
				background: #FF4F4F;
				border-radius: 50%;
				position: absolute;
				right: -8rpx;
				top: 0;
			}
		}
		.right{
			width: 510rpx;
			height: 160rpx;
			display: flex;
			justify-content:space-between;
			align-items: center;
			border-bottom:1rpx rgba(0, 0, 0, 0.1) solid ;
		}
		.detail{
			height: 44rpx;
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.87);
			line-height: 44rpx;
		}
		.into{
			font-size: 64rpx;
		}
	}
	
</style>
